﻿Imports BigDecimals.Math
Imports BigDecimals

Module Module1

  Sub Main()
  
    Dim t1 As BigDecimal = -4.9
    Dim t2 As BigDecimal = 4.9
    Dim t1f As BigDecimal = t1.Ceiling
    Dim t2f As BigDecimal = t2.Ceiling
    Dim BNs As New List(Of BigDecimal) From {BigDecimal.MinusOne,
                                          BigDecimal.Zero,
                                          BigDecimal.One,
                                           New BigDecimal("400.25"),
                                           New BigDecimal("-400.253")
                                        }
    For Each _x As BigDecimal In BNs
      Console.WriteLine(_x.ToString)

    Next

    Dim n1 As BigDecimal = 1 ' BigDecimal.One
    Dim n2 As BigDecimal = (n1 + n1 + n1)
    Dim rn As BigDecimal = (n2.Recipricol)
    Console.WriteLine(rn.ToString)
    Dim RN2 = rn.Recipricol()
    Console.WriteLine(RN2.ToString)

    Dim n3 As BigDecimal = n2 + n1 - BigDecimal.MinusOne
    Dim n4 As BigDecimal = BigDecimal.PointOne
    Dim n5 As BigDecimal = n4 - n3
    Console.WriteLine(n5)
    Dim n6 As BigDecimal = n3 * n4
    Dim n7 As BigDecimal = n4 * n3
    Dim n8 = Math.Abs(n5.Abs)
    Dim n9 = BigDecimal.MinusOne * n5
    Console.WriteLine(n9.ToString)

    Console.WriteLine(New BigDecimal("250") Mod New BigDecimal("100"))
    Console.WriteLine(New BigDecimal("250") \ New BigDecimal("100"))
    Console.WriteLine(New BigDecimal("17").GCD(New BigDecimal("97")))

    Dim a As BigDecimal = Nothing
    Dim r = BigDecimal.TryParse("-1.23", a)
    Console.WriteLine("Comparer Testing")

    Dim CmpR As Integer = 0
    For Each BN_A As BigDecimal In BNs
      For Each BN_B As BigDecimal In BNs
        CmpR = BN_A.CompareTo(BN_B)
        Console.WriteLine("A: {0}{3}B: {1}{3}CmpR: {2}", BN_A, BN_B, {"<", "=", ">"}(CmpR + 1), ControlChars.Tab & ControlChars.Tab)

      Next
    Next
    If BNs(0) >= BNs(4) Then Console.WriteLine("It works")

    Dim dn1 As New BigDecimal("3")
    Dim dn2 As New BigDecimal("6025")
    Dim dr = dn1 / dn2
    Console.WriteLine(dr.ToString)
    Dim dn3 As New BigDecimal("1")
    Dim dn4 As New BigDecimal("3.5")
    Dim dr2 = dn3 / dn4
    Console.WriteLine()
    Console.WriteLine("{0} / {1}", dn3, dn4)
    Console.WriteLine(dr2.ToString)
    Dim dn7 As New BigDecimal("-1")
    Dim dn8 As New BigDecimal("3.5")
    Dim dr9 = dn7 / dn8
    Console.WriteLine()
    Console.WriteLine("{0} / {1}", dn7, dn8)
    Console.WriteLine(dr9.ToString)




    Console.Read()
  End Sub

End Module

